class TradeRecordDao {
    public data = {
        loginright: LobsterAPI.ProgramData('loginright'),
        dbConn: LobsterAPI.ProgramData('dbConn'),
        resultdata: { data: {} }
    }
    /**
     * 获取交易信息
     * @param orderNo 
     */
    getTradeRecord(orderNo) {
        var self = this;
        var strsql = " select * from TR_TradeRecord  where OrderNo=?";
        var dbparams = [];
        dbparams.push(orderNo);
        return LobsterAPI.DbGetJsonData(self.data.dbConn, strsql, dbparams);
    }
    /**
    * 获取交易信息
    * @param tradeNo 
    */
    getTradeRecordByTradeNo(tradeNo) {
        var self = this;
        var strsql = " select * from TR_TradeRecord  where TradeNo=?";
        var dbparams = [];
        dbparams.push(tradeNo);
        return LobsterAPI.DbGetJsonObject(self.data.dbConn, strsql, dbparams);
    }
    /**
     * 获取交易分页信息
     * @param userId 
     * @param page 
     * @param limit 
     * @returns 
     */
    getTradelist(page, limit,userId) {
        try {
            var self = this;
            var strsql = " select * from TR_TradeRecord where UserId=? and  WorkId=? and tradeStatus=2"
            var dbparams = [];
            var workId=LobsterAPI.ProgramData('workid')
            dbparams.push(userId);
            dbparams.push(workId);
            LobsterAPI.TrackLog("gettradelist-workid",workId);
            var pageInfo = {
                key: " TradeId desc ",
                page: page,
                perPage: limit,
                totalRecord: 0,
                totalPage: 0,
            };
            return { data: LobsterAPI.DbGetJsonData(self.data.dbConn, strsql, dbparams, pageInfo), count: pageInfo.totalRecord };
        } catch (e) {
            throw e;
        }
    }
    /**
     * 获取分润规则
     */
    getsharerule(userId, ruleCode) {
        var self = this;
        var strsql = "select a.* from CL_ShareRule a\
        inner join CL_ShareAccountRelation b\
        on a.RuleCode = b.RuleCode\
        where b.UserId =?\
        and a.RuleCode =?\
        and a.WorkId = ? ";
        var dbparams = [];
        dbparams.push(userId);
        dbparams.push(ruleCode);
        return LobsterAPI.DbGetJsonObject(self.data.dbConn, strsql, dbparams);
    }
}